package com.stagecommon.common.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: yxl
 * @since: 2021-11-23
 **/
@Configuration
public class FileConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/img/userAvatar/**", "/img/indexImg/**",
                "/img/worksImg/**", "/img/worksAudio/**", "/img/worksVideo/**","/img/ordersFile/**","/img/worksFile/**","/img/poster/**")
        .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                + "img" + System.getProperty("file.separator") + "userAvatar" + System.getProperty("file.separator"))
        .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                +"img" + System.getProperty("file.separator") + "indexImg" + System.getProperty("file.separator"))
        .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                +"img" + System.getProperty("file.separator") + "worksImg" + System.getProperty("file.separator"))
        .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                +"img" + System.getProperty("file.separator") + "worksAudio" + System.getProperty("file.separator"))
        .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                 +"img" + System.getProperty("file.separator") + "worksVideo" + System.getProperty("file.separator"))
        .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                +"img" + System.getProperty("file.separator") + "ordersFile" + System.getProperty("file.separator"))
                .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                        +"img" + System.getProperty("file.separator") + "worksFile" + System.getProperty("file.separator"))
                .addResourceLocations("file:" + System.getProperty("user.dir") + System.getProperty("file.separator")
                        +"img" + System.getProperty("file.separator") + "poster" + System.getProperty("file.separator"));
    }
}
